#ifndef DRAWABLEOBJECT_HPP_
# define DRAWABLEOBJECT_HPP_

# include <glew.h>
# include "IDrawable.hpp"
# include "VertexAttributes.hpp"
# include "Shader.hpp"
# include "VBO.hpp"
# include "Mat.hpp"

class DrawableObject: public IDrawable
{
public:
	DrawableObject();
	DrawableObject(Shader& shader);
    DrawableObject(DrawableObject const& copy);
	virtual ~DrawableObject(void);

    virtual void        init(void);

    virtual void        begin(void);
    virtual void        draw(void);
    virtual void        end(void);

    void                shaderAttributesEnable();
    void                shaderAttributesDisable();
    void                shaderAttributesGet();
    void                shaderAttributesSendData();

	void				setShader(Shader* shader);
    Shader*             getShader();

	void				setVertices(unsigned int nbVertices, VertexAttributes* attributes);
    VertexAttributes*	getVertices(void);
    void                setNbVertices(const unsigned int nbVertices);
    unsigned int		getNbVertices() const;

	void				setIndex(unsigned int nbIndex, unsigned int* index);
    unsigned int*		getIndex(void);
    void                setNbIndex(const unsigned int nbIndex);
	unsigned int		getNbIndex() const;

    VertexAttributes*   findVertex(const unsigned char r, const unsigned char g, const unsigned char b, int& index);

    void                updateVBO();

    void                translate(const float x, const float y, const float z);
    Vec3f&              getPosition();
    void                setPositionX(const float x);
    void                setPositionY(const float y);
    void                setPositionZ(const float z);
    void                setPosition(const float x, const float y, const float z);
protected:
	unsigned int		_nbVertices;
	unsigned int		_nbIndex;
	VertexAttributes*	_vertices;
	unsigned int*		_index;

	Shader*				_shader;
	GLuint				_vbo[VBO_SIZE];
	int					_attrib[ATTRIB_SIZE];

    Vec3f               _position;
};

#endif // !DRAWABLEOBJECT_HPP_
